/*
 * @Date: 2023-03-14 17:46:56
 * @LastEditors: Chuying
 * @LastEditTime: 2023-04-01 15:09:45
 * @Description:
 */
import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  ManyToMany,
  JoinTable,
} from 'typeorm';
import { Category } from '../../category/entities/category.entity';
import { ApiProperty } from '@nestjs/swagger';

@Entity()
export class Posting {
  @ApiProperty({ description: '帖子id' })
  @PrimaryGeneratedColumn()
  id: number;
//   @ApiProperty({ description: '标题' })
//   @Column({
//     name: 'title',
//     length: 50,
//     nullable: false,
//   })
//   title: string;
  @ApiProperty({ description: '内容' })
  @Column()
  content: string;
  @ApiProperty({ description: '图片' })
  @Column()
  images: string;

  @Column({
    name: 'create_time',
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP',
  })
  createTime: Date;

  @Column({
    name: 'update_time',
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP',
  })
  updateTime: Date;
  @ApiProperty({ description: '用户id' })
  @Column()
  userId: string;
  @ApiProperty({ description: '地址' })
  @Column()
  address: string;

  // 分类
  @ManyToMany(() => Category, (cate) => cate.id)
  @JoinTable()
  categories: Category[];
}
